#include "stream.h"

int gvl_write_byte_overflow_(gvl_byte_writer* self, unsigned char byte)
{
	gvl_bucket_data_mem* bucket = self->cur_bucket;
	gvl_stream* sink = self->sink;
	unsigned len = bucket->len;
	int result = gvl_stream_put(sink, gvl_bucket_new(0, len, &bucket->base));
	unsigned len_new = sink->initial_bucket_len;
	
	bucket = gvl_bucket_data_mem_new(len_new);
	
	self->cur_bucket = bucket;
	self->next = bucket->data;
	self->limit = bucket->data + len_new;
	
	*self->next++ = byte;
	return result;
}
